package cn.ren.hai.base.entity;

import cn.ren.hai.core.entity.BaseEntity;
import cn.ren.hai.core.enums.DBFieldType;
import cn.ren.hai.core.util.StringUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 表字段
 * </p>
 *
 * @author 王道
 * @since 2022-01-15
 */
@Getter
@Setter
@TableName("rh_table_field")
@ApiModel(value = "RhTableField对象", description = "表字段")
public class RhTableField extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("字段名称")
    @TableField("name")
    private String name;

    @TableField(exist = false)
    private String dataIndex;

    public String getDataIndex(){

        return StringUtil.underscoreToCamelCase(this.name) ;
    }

    @ApiModelProperty("类型")
    @TableField("type")
    private DBFieldType type;

    @ApiModelProperty("描述")
    @TableField("remark")
    private String remark;

    @ApiModelProperty("长度")
    @TableField("length")
    private Integer length;

    @ApiModelProperty("关联表")
    @TableField("table_id")
    private Long tableId;

    @ApiModelProperty("显示名称")
    @TableField("title")
    private String title;

    @ApiModelProperty("数值精度(最大位数)")
    @TableField("numeric_precision")
    private Integer numericPrecision;

    @ApiModelProperty("小数精度")
    @TableField("numeric_scale")
    private Integer numericScale;




}
